package com.lzy.common.lang;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 统一封装结果集
 * @autor shkstart
 * @create 2021-01-14 10:33)
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {

    private int code; //状态码
    private String msg; //提示信息
    private Object data;//数据



    public static Result succ(int code,String msg,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    //200
    public static Result succ(Object data){
        return new Result(200,"操作成功",data);
    }

    //异常
    public static Result fail(String meg,Object data){
        return new Result(400,meg,data);
    }
    //异常再封装
    public static Result fail(String meg){
        return new Result(400,meg,null);
    }


}
